package com.niu.service.impl;

import com.niu.mapper.DeptMapper;
import com.niu.mapper.EmpMapper;
import com.niu.pojo.Dept;
import com.niu.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class DeptServiceImpl implements DeptService {

    @Autowired
    private DeptMapper deptMapper;

    @Override
    public List<Dept> getList() {
        return deptMapper.getAll();
    }

    @Override
    public int deletById(Integer id) {
        // 删除部门信息
        return deptMapper.deletById(id);
    }

    @Override
    public int insertDept(Dept dept) {
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());
        return deptMapper.insertDept(dept);
    }

    @Override
    public Dept getById(Integer id) {
        return deptMapper.getById(id);
    }

    @Override
    public int updateById(Dept dept) {
        dept.setUpdateTime(LocalDateTime.now());
        return deptMapper.updateById(dept);
    }
}
